package com.example.springbootdemo.sevice;

import cn.hutool.http.webservice.SoapClient;
import com.example.springbootdemo.config.WebserviceConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  webservice接口
 * </p>
 *
 * @author yurenwei
 * @since 2023/9/6
 */
@Slf4j
@Service
public class WebserviceService {

    @Autowired
    private WebserviceConfig webserviceConfig;

    public void test() {
        Map<String, Object> map = new HashMap<>();
        map.put("billid",1);
        map.put("billtype","62");
        map.put("buttflag","newzcpt");
        map.put("enforced","");

        // 新建客户端
        SoapClient client = SoapClient.create(webserviceConfig.getUrl())
                // 设置要请求的方法和对应的命名空间
                .setMethod(webserviceConfig.getApproveCancel(), webserviceConfig.getNamespace())
                // 设置参数
                .setParams(map, false);
        // 发送请求
        String result = client.send();
        log.info("result:{}",result);
    }
}
